/* Copyright (C) Abu Rizal, 2009.
 * 
 * This file is part of QurText.
 * 
 * QurText is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * QurText is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with QurText. If not, see <http://www.gnu.org/licenses/>.
 */
package qurtext.client;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.TreeMap;

import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class NavigationPresenter {
	private QurTextServiceAsync qurTextService;
	private NavigationView navigationView;
	private MainPresenter mainPresenter;
	private TreeMap<String,Integer> tokenSectionMap = new TreeMap<String, Integer>();
	
	public QurTextServiceAsync getQurTextService() {
		return qurTextService;
	}

	public void setQurTextService(QurTextServiceAsync qurTextService) {
		this.qurTextService = qurTextService;
	}

	public void initAllSections() {
		initAllSections(mainPresenter.getAllSections().iterator());
	}

	private void initAllSections(final Iterator<ClientSection> iterator) {
		ClientSection section = iterator.next();
		if (null==section) {
			String statusText = "Click on a button!";
			navigationView.setStatusText(statusText);
			return;
		}
		String statusText = "Initializing " + section.chapter + ":" + section.verse;
		navigationView.setStatusText(statusText);
		qurTextService.initSectionVerses(section.chapter, section.verse, new AsyncCallback<Void>() {

			@Override
			public void onFailure(Throwable caught) {
				mainPresenter.handleError(caught);
				initAllSections(iterator);	
			}

			@Override
			public void onSuccess(Void result) {
				initAllSections(iterator);	
			}
		});
	}

	public void setNavigationView(NavigationView navigationView) {
		this.navigationView = navigationView;
	}

	public NavigationView getNavigationView() {
		return navigationView;
	}

	public void setMainPresenter(MainPresenter mainPresenter) {
		this.mainPresenter = mainPresenter;
	}

	public MainPresenter getMainPresenter() {
		return mainPresenter;
	}

	public void initAllLiterals() {
		ClientSection section = mainPresenter.getCurrentSection();
		navigationView.setInitAllLiteralButtonEnabled(false);
		initAllLiterals(""+section.chapter+":"+section.verse+":0");
	}

	private void initAllLiterals(final String start) {
		if (null==start) {
			navigationView.setStatusText("Click on a button!");
			return;
		}
		navigationView.setStatusText("Initializing " + start);
		qurTextService.initAllLiterals(start, new AsyncCallback<String>() {

			@Override
			public void onFailure(Throwable caught) {
				if ( ! mainPresenter.isProduction())
					mainPresenter.handleError(caught);//never stop on production
				Timer timer=new Timer() {

					@Override
					public void run() {
						initAllLiterals(start);	
						
					}
					
				};
				timer.schedule(5000);
			}

			@Override
			public void onSuccess(String result) {
				initAllLiterals(result);	
			}
		});
	}

	public void initSectionList() {
		int start=1;
		initSectionList(start);
	}

	private void initSectionList(int start) {
		if (start>=0) {
			navigationView.setInitButtonEnabled(false);
			navigationView.setStatusText("Initializing " + start);
		} else {
			navigationView.setStatusText("Click on a button!");
			onNavigationPresenterLoad();
			return;
		}
		qurTextService.initChapterList(start, new AsyncCallback<Integer> () {

			@Override
			public void onFailure(Throwable caught) {
				mainPresenter.handleError(caught);
			}

			@Override
			public void onSuccess(Integer start) {
				initSectionList(start);
			}
			
		});
	}
	
	public void onNavigationPresenterLoad() {
		int JUZ_NO=0;
		int SECTION_NO=1;
		int CHAPTER_NO=2;
		int START_VERSE_NO=3;
		int END_VERSE_NO=4;   
		int[][] JUZ_LIST= {
			{1,0,1,1,7},
			{1,1,2,1,7},
			{1,2,2,8,20},
			{1,3,2,21,29},
			{1,4,2,30,39},
			{1,5,2,40,46},
			{1,6,2,47,59},
			{1,7,2,60,61},
			{1,8,2,62,71},
			{1,9,2,72,82},
			{1,10,2,83,86},
			{1,11,2,87,96},
			{1,12,2,97,103},
			{1,13,2,104,112},
			{1,14,2,113,121},
			{1,15,2,122,129},
			{1,16,2,130,141},
			{2,17,2,142,147},
			{2,18,2,148,152},
			{2,19,2,153,163},
			{2,20,2,164,167},
			{2,21,2,168,176},
			{2,22,2,177,182},
			{2,23,2,183,188},
			{2,24,2,189,196},
			{2,25,2,197,210},
			{2,26,2,211,216},
			{2,27,2,217,221},
			{2,28,2,222,228},
			{2,29,2,229,231},
			{2,30,2,232,235},
			{2,31,2,236,242},
			{2,32,2,243,248},
			{2,33,2,249,253},
			{3,33,2,253,0},
			{3,34,2,254,257},
			{3,35,2,258,260},
			{3,36,2,261,266},
			{3,37,2,267,273},
			{3,38,2,274,281},
			{3,39,2,282,283},
			{3,40,2,284,286},
			{3,41,3,1,9},
			{3,42,3,10,20},
			{3,43,3,21,30},
			{3,44,3,31,41},
			{3,45,3,42,54},
			{3,46,3,55,63},
			{3,47,3,64,71},
			{3,48,3,72,80},
			{3,49,3,81,91},
			{3,50,3,92,101},
			{4,50,3,93,0},
			{4,51,3,102,109},
			{4,52,3,110,120},
			{4,53,3,121,129},
			{4,54,3,130,143},
			{4,55,3,144,148},
			{4,56,3,149,155},
			{4,57,3,156,171},
			{4,58,3,172,180},
			{4,59,3,181,189},
			{4,60,3,190,200},
			{4,61,4,1,10},
			{4,62,4,11,14},
			{4,63,4,15,22},
			{4,64,4,23,25},
			{5,64,4,24,0},
			{5,65,4,26,33},
			{5,66,4,34,42},
			{5,67,4,43,50},
			{5,68,4,51,59},
			{5,69,4,60,70},
			{5,70,4,71,76},
			{5,71,4,77,87},
			{5,72,4,88,91},
			{5,73,4,92,96},
			{5,74,4,97,100},
			{5,75,4,101,104},
			{5,76,4,105,112},
			{5,77,4,113,115},
			{5,78,4,116,126},
			{5,79,4,127,134},
			{5,80,4,135,141},
			{5,81,4,142,152},
			{6,81,4,148,0},
			{6,82,4,153,162},
			{6,83,4,163,171},
			{6,84,4,172,176},
			{6,85,5,1,5},
			{6,86,5,6,11},
			{6,87,5,12,19},
			{6,88,5,20,26},
			{6,89,5,27,34},
			{6,90,5,35,43},
			{6,91,5,44,50},
			{6,92,5,51,56},
			{6,93,5,57,66},
			{6,94,5,67,77},
			{6,95,5,78,86},
			{7,95,5,82,0},
			{7,96,5,87,93},
			{7,97,5,94,100},
			{7,98,5,101,108},
			{7,99,5,109,115},
			{7,100,5,116,120},
			{7,101,6,1,10},
			{7,102,6,11,20},
			{7,103,6,21,30},
			{7,104,6,31,41},
			{7,105,6,42,50},
			{7,106,6,51,55},
			{7,107,6,56,60},
			{7,108,6,61,70},
			{7,109,6,71,82},
			{7,110,6,83,90},
			{7,111,6,91,94},
			{7,112,6,95,100},
			{7,113,6,101,110},
			{8,114,6,111,121},
			{8,115,6,122,129},
			{8,116,6,130,140},
			{8,117,6,141,144},
			{8,118,6,145,150},
			{8,119,6,151,154},
			{8,120,6,155,165},
			{8,121,7,1,10},
			{8,122,7,11,25},
			{8,123,7,26,31},
			{8,124,7,32,39},
			{8,125,7,40,47},
			{8,126,7,48,53},
			{8,127,7,54,58},
			{8,128,7,59,64},
			{8,129,7,65,72},
			{8,130,7,73,84},
			{8,131,7,85,93},
			{9,131,7,88,0},
			{9,132,7,94,99},
			{9,133,7,100,108},
			{9,134,7,109,126},
			{9,135,7,127,129},
			{9,136,7,130,141},
			{9,137,7,142,147},
			{9,138,7,148,151},
			{9,139,7,152,157},
			{9,140,7,158,162},
			{9,141,7,163,171},
			{9,142,7,172,181},
			{9,143,7,182,188},
			{9,144,7,189,206},
			{9,145,8,1,10},
			{9,146,8,11,19},
			{9,147,8,20,28},
			{9,148,8,29,37},
			{9,149,8,38,44},
			{10,149,8,41,0},
			{10,150,8,45,48},
			{10,151,8,49,58},
			{10,152,8,59,64},
			{10,153,8,65,69},
			{10,154,8,70,75},
			{10,155,9,1,6},
			{10,156,9,7,16},
			{10,157,9,17,24},
			{10,158,9,25,29},
			{10,159,9,30,37},
			{10,160,9,38,42},
			{10,161,9,43,59},
			{10,162,9,60,66},
			{10,163,9,67,72},
			{10,164,9,73,80},
			{10,165,9,81,89},
			{10,166,9,90,99},
			{11,166,9,93,0},
			{11,167,9,100,110},
			{11,168,9,111,118},
			{11,169,9,119,122},
			{11,170,9,123,129},
			{11,171,10,1,10},
			{11,172,10,11,20},
			{11,173,10,21,30},
			{11,174,10,31,40},
			{11,175,10,41,53},
			{11,176,10,54,60},
			{11,177,10,61,70},
			{11,178,10,71,82},
			{11,179,10,83,92},
			{11,180,10,93,103},
			{11,181,10,104,109},
			{11,182,11,1,8},
			{12,182,11,6,0},
			{12,183,11,9,24},
			{12,184,11,25,35},
			{12,185,11,36,49},
			{12,186,11,50,60},
			{12,187,11,61,68},
			{12,188,11,69,83},
			{12,189,11,84,95},
			{12,190,11,96,109},
			{12,191,11,110,123},
			{12,192,12,1,6},
			{12,193,12,7,20},
			{12,194,12,21,29},
			{12,195,12,30,35},
			{12,196,12,36,42},
			{12,197,12,43,49},
			{12,198,12,50,57},
			{13,198,12,53,0},
			{13,199,12,58,68},
			{13,200,12,69,79},
			{13,201,12,80,93},
			{13,202,12,94,104},
			{13,203,12,105,111},
			{13,204,13,1,7},
			{13,205,13,8,18},
			{13,206,13,19,26},
			{13,207,13,27,31},
			{13,208,13,32,37},
			{13,209,13,38,43},
			{13,210,14,1,6},
			{13,211,14,7,12},
			{13,212,14,13,21},
			{13,213,14,22,27},
			{13,214,14,28,34},
			{13,215,14,35,41},
			{13,216,14,42,52},
			{14,217,15,1,15},
			{14,218,15,16,25},
			{14,219,15,26,44},
			{14,220,15,45,60},
			{14,221,15,61,79},
			{14,222,15,80,99},
			{14,223,16,1,9},
			{14,224,16,10,21},
			{14,225,16,22,25},
			{14,226,16,26,34},
			{14,227,16,35,40},
			{14,228,16,41,50},
			{14,229,16,51,60},
			{14,230,16,61,65},
			{14,231,16,66,70},
			{14,232,16,71,76},
			{14,233,16,77,83},
			{14,234,16,84,89},
			{14,235,16,90,100},
			{14,236,16,101,110},
			{14,237,16,111,119},
			{14,238,16,120,128},
			{15,239,17,1,10},
			{15,240,17,11,22},
			{15,241,17,23,30},
			{15,242,17,31,40},
			{15,243,17,41,52},
			{15,244,17,53,60},
			{15,245,17,61,70},
			{15,246,17,71,77},
			{15,247,17,78,84},
			{15,248,17,85,93},
			{15,249,17,94,100},
			{15,250,17,101,111},
			{15,251,18,1,12},
			{15,252,18,13,17},
			{15,253,18,18,22},
			{15,254,18,23,31},
			{15,255,18,32,44},
			{15,256,18,45,49},
			{15,257,18,50,53},
			{15,258,18,54,59},
			{15,259,18,60,70},
			{15,260,18,71,82},
			{16,260,18,75,0},
			{16,261,18,83,101},
			{16,262,18,102,110},
			{16,263,19,1,15},
			{16,264,19,16,40},
			{16,265,19,41,50},
			{16,266,19,51,65},
			{16,267,19,66,82},
			{16,268,19,83,98},
			{16,269,20,1,24},
			{16,270,20,25,54},
			{16,271,20,55,76},
			{16,272,20,77,89},
			{16,273,20,90,104},
			{16,274,20,105,115},
			{16,275,20,116,128},
			{16,276,20,129,135},
			{17,277,21,1,10},
			{17,278,21,11,29},
			{17,279,21,30,41},
			{17,280,21,42,50},
			{17,281,21,51,75},
			{17,282,21,76,93},
			{17,283,21,94,112},
			{17,284,22,1,10},
			{17,285,22,11,22},
			{17,286,22,23,25},
			{17,287,22,26,33},
			{17,288,22,34,38},
			{17,289,22,39,48},
			{17,290,22,49,57},
			{17,291,22,58,64},
			{17,292,22,65,72},
			{17,293,22,73,78},
			{18,294,23,1,22},
			{18,295,23,23,32},
			{18,296,23,33,50},
			{18,297,23,51,77},
			{18,298,23,78,92},
			{18,299,23,93,118},
			{18,300,24,1,10},
			{18,301,24,11,20},
			{18,302,24,21,26},
			{18,303,24,27,34},
			{18,304,24,35,40},
			{18,305,24,41,50},
			{18,306,24,51,57},
			{18,307,24,58,61},
			{18,308,24,62,64},
			{18,309,25,1,9},
			{18,310,25,10,20},
			{19,311,25,21,34},
			{19,312,25,35,44},
			{19,313,25,45,60},
			{19,314,25,61,77},
			{19,315,26,1,9},
			{19,316,26,10,33},
			{19,317,26,34,52},
			{19,318,26,53,69},
			{19,319,26,70,104},
			{19,320,26,105,122},
			{19,321,26,123,140},
			{19,322,26,141,159},
			{19,323,26,160,175},
			{19,324,26,176,191},
			{19,325,26,192,227},
			{19,326,27,1,14},
			{19,327,27,15,31},
			{19,328,27,32,44},
			{19,329,27,45,58},
			{20,329,27,56,0},
			{20,330,27,59,66},
			{20,331,27,67,82},
			{20,332,27,83,93},
			{20,333,28,1,13},
			{20,334,28,14,21},
			{20,335,28,22,28},
			{20,336,28,29,42},
			{20,337,28,43,50},
			{20,338,28,51,60},
			{20,339,28,61,75},
			{20,340,28,76,82},
			{20,341,28,83,88},
			{20,342,29,1,13},
			{20,343,29,14,22},
			{20,344,29,23,30},
			{20,345,29,31,44},
			{20,346,29,45,51},
			{21,346,29,46,0},
			{21,347,29,52,63},
			{21,348,29,64,69},
			{21,349,30,1,10},
			{21,350,30,11,19},
			{21,351,30,20,27},
			{21,352,30,28,40},
			{21,353,30,41,53},
			{21,354,30,54,60},
			{21,355,31,1,11},
			{21,356,31,12,19},
			{21,357,31,20,30},
			{21,358,31,31,34},
			{21,359,32,1,11},
			{21,360,32,12,22},
			{21,361,32,23,30},
			{21,362,33,1,8},
			{21,363,33,9,20},
			{21,364,33,21,27},
			{21,365,33,28,34},
			{22,365,33,31,0},
			{22,366,33,35,40},
			{22,367,33,41,52},
			{22,368,33,53,58},
			{22,369,33,59,68},
			{22,370,33,69,73},
			{22,371,34,1,9},
			{22,372,34,10,21},
			{22,373,34,22,30},
			{22,374,34,31,36},
			{22,375,34,37,45},
			{22,376,34,46,54},
			{22,377,35,1,7},
			{22,378,35,8,14},
			{22,379,35,15,26},
			{22,380,35,27,37},
			{22,381,35,38,45},
			{22,382,36,1,12},
			{22,383,36,13,32},
			{23,383,36,28,0},
			{23,384,36,33,50},
			{23,385,36,51,67},
			{23,386,36,68,83},
			{23,387,37,1,21},
			{23,388,37,22,74},
			{23,389,37,75,113},
			{23,390,37,114,138},
			{23,391,37,139,182},
			{23,392,38,1,14},
			{23,393,38,15,26},
			{23,394,38,27,40},
			{23,395,38,41,64},
			{23,396,38,65,88},
			{23,397,39,1,9},
			{23,398,39,10,21},
			{23,399,39,22,31},
			{24,400,39,32,41},
			{24,401,39,42,52},
			{24,402,39,53,63},
			{24,403,39,64,70},
			{24,404,39,71,75},
			{24,405,40,1,9},
			{24,406,40,10,20},
			{24,407,40,21,27},
			{24,408,40,28,37},
			{24,409,40,38,50},
			{24,410,40,51,60},
			{24,411,40,61,68},
			{24,412,40,69,78},
			{24,413,40,79,85},
			{24,414,41,1,8},
			{24,415,41,9,18},
			{24,416,41,19,25},
			{24,417,41,26,32},
			{24,418,41,33,44},
			{24,419,41,45,54},
			{25,419,41,47,0},
			{25,420,42,1,9},
			{25,421,42,10,19},
			{25,422,42,20,29},
			{25,423,42,30,43},
			{25,424,42,44,53},
			{25,425,43,1,15},
			{25,426,43,16,25},
			{25,427,43,26,35},
			{25,428,43,36,45},
			{25,429,43,46,56},
			{25,430,43,57,67},
			{25,431,43,68,89},
			{25,432,44,1,29},
			{25,433,44,30,42},
			{25,434,44,43,59},
			{25,435,45,1,11},
			{25,436,45,12,21},
			{25,437,45,22,26},
			{25,438,45,27,37},
			{26,439,46,1,10},
			{26,440,46,11,20},
			{26,441,46,21,26},
			{26,442,46,27,35},
			{26,443,47,1,11},
			{26,444,47,12,19},
			{26,445,47,20,28},
			{26,446,47,29,38},
			{26,447,48,1,10},
			{26,448,48,11,17},
			{26,449,48,18,26},
			{26,450,48,27,29},
			{26,451,49,1,10},
			{26,452,49,11,18},
			{26,453,50,1,15},
			{26,454,50,16,29},
			{26,455,50,30,45},
			{26,456,51,1,23},
			{26,457,51,24,46},
			{27,457,51,31,0},
			{27,458,51,47,60},
			{27,459,52,1,28},
			{27,460,52,29,49},
			{27,461,53,1,25},
			{27,462,53,26,32},
			{27,463,53,33,62},
			{27,464,54,1,22},
			{27,465,54,23,40},
			{27,466,54,41,55},
			{27,467,55,1,25},
			{27,468,55,26,45},
			{27,469,55,46,78},
			{27,470,56,1,38},
			{27,471,56,39,74},
			{27,472,56,75,96},
			{27,473,57,1,10},
			{27,474,57,11,19},
			{27,475,57,20,25},
			{27,476,57,26,29},
			{28,477,58,1,6},
			{28,478,58,7,13},
			{28,479,58,14,22},
			{28,480,59,1,10},
			{28,481,59,11,17},
			{28,482,59,18,24},
			{28,483,60,1,6},
			{28,484,60,7,13},
			{28,485,61,1,9},
			{28,486,61,10,14},
			{28,487,62,1,8},
			{28,488,62,9,11},
			{28,489,63,1,8},
			{28,490,63,9,11},
			{28,491,64,1,10},
			{28,492,64,11,18},
			{28,493,65,1,7},
			{28,494,65,8,12},
			{28,495,66,1,7},
			{28,496,66,8,12},
			{29,497,67,1,14},
			{29,498,67,15,30},
			{29,499,68,1,33},
			{29,500,68,35,52},
			{29,501,69,1,37},
			{29,502,69,38,52},
			{29,503,70,1,35},
			{29,504,70,36,44},
			{29,505,71,1,20},
			{29,506,71,21,28},
			{29,507,72,1,19},
			{29,508,72,20,28},
			{29,509,73,1,19},
			{29,510,73,20,20},
			{29,511,74,1,31},
			{29,512,74,32,56},
			{29,513,75,1,30},
			{29,514,75,31,40},
			{29,515,76,1,22},
			{29,516,76,23,31},
			{29,517,77,1,40},
			{29,518,77,41,50},
			{30,519,78,1,30},
			{30,520,78,31,40},
			{30,521,79,1,26},
			{30,522,79,27,46},
			{30,523,80,1,42},
			{30,524,81,1,29},
			{30,525,82,1,19},
			{30,526,83,1,36},
			{30,527,84,1,25},
			{30,528,85,1,22},
			{30,529,86,1,17},
			{30,530,87,1,19},
			{30,531,88,1,26},
			{30,532,89,1,30},
			{30,533,90,1,20},
			{30,534,91,1,15},
			{30,535,92,1,21},
			{30,536,93,1,11},
			{30,537,94,1,8},
			{30,538,95,1,8},
			{30,539,96,1,19},
			{30,540,97,1,5},
			{30,541,98,1,8},
			{30,542,99,1,8},
			{30,543,100,1,11},
			{30,544,101,1,11},
			{30,545,102,1,8},
			{30,546,103,1,3},
			{30,547,104,1,9},
			{30,548,105,1,5},
			{30,549,106,1,4},
			{30,550,107,1,7},
			{30,551,108,1,3},
			{30,552,109,1,6},
			{30,553,110,1,3},
			{30,554,111,1,5},
			{30,555,112,1,4},
			{30,556,113,1,5},
			{30,557,114,1,6},
		};
		
		ArrayList<ClientJuz> juzList = new ArrayList<ClientJuz>();
		ClientJuz juz=new ClientJuz();
	    ArrayList<ClientSection> sectionList= new ArrayList<ClientSection>();
		for (int i=0;i<JUZ_LIST.length;i++) {
			if (JUZ_LIST[i][JUZ_NO]!=juz.juzNo) {
				juz=new ClientJuz(JUZ_LIST[i][JUZ_NO]);
				juzList.add(juz);
			}
			String token = "" + JUZ_LIST[i][CHAPTER_NO] + ":" + JUZ_LIST[i][START_VERSE_NO];
			juz.tokens.add(token);
			tokenSectionMap.put(token,Integer.valueOf(JUZ_LIST[i][SECTION_NO]));

			if (JUZ_LIST[i][END_VERSE_NO]==0) continue;
			ClientSection section = new ClientSection(JUZ_LIST[i][SECTION_NO],JUZ_LIST[i][CHAPTER_NO],JUZ_LIST[i][START_VERSE_NO],JUZ_LIST[i][END_VERSE_NO]);
			sectionList.add(section);
		}
		mainPresenter.setAllSections(sectionList);
	    navigationView.showJuzList(juzList);
		showChapterList();
	}

	private void showChapterList() {
		String[][] chapterNames={
				{"\u0627\u0644\u0641\u0627\u062a\u062d\u0629","Al-Faatiha"},
				{"\u0627\u0644\u0628\u0642\u0631\u0629","Al-Baqara"},
				{"\u0622\u0644\u0020\u0639\u0645\u0631\u0627\u0646","Aal-i-Imraan"},
				{"\u0627\u0644\u0646\u0633\u0627\u0621","An-Nisaa"},
				{"\u0627\u0644\u0645\u0627\u0626\u062f\u0629","Al-Maaida"},
				{"\u0627\u0644\u0623\u0646\u0639\u0627\u0645","Al-An'aam"},
				{"\u0627\u0644\u0623\u0639\u0631\u0627\u0641","Al-A'raaf"},
				{"\u0627\u0644\u0623\u0646\u0641\u0627\u0644","Al-Anfaal"},
				{"\u0627\u0644\u062a\u0648\u0628\u0629","At-Tawba"},
				{"\u064a\u0648\u0646\u0633","Yunus"},
				{"\u0647\u0648\u062f","Hud"},
				{"\u064a\u0648\u0633\u0641","Yusuf"},
				{"\u0627\u0644\u0631\u0639\u062f","Ar-Ra'd"},
				{"\u0627\u0628\u0631\u0627\u0647\u064a\u0645","Ibrahim"},
				{"\u0627\u0644\u062d\u062c\u0631","Al-Hijr"},
				{"\u0627\u0644\u0646\u062d\u0644","An-Nahl"},
				{"\u0627\u0644\u0625\u0633\u0631\u0627\u0621","Al-Israa"},
				{"\u0627\u0644\u0643\u0647\u0641","Al-Kahf"},
				{"\u0645\u0631\u064a\u0645","Maryam"},
				{"\u0637\u0647","Taa-Haa"},
				{"\u0627\u0644\u0623\u0646\u0628\u064a\u0627\u0621","Al-Anbiyaa"},
				{"\u0627\u0644\u062d\u062c","Al-Hajj"},
				{"\u0627\u0644\u0645\u0624\u0645\u0646\u0648\u0646","Al-Muminoon"},
				{"\u0627\u0644\u0646\u0648\u0631","An-Noor"},
				{"\u0627\u0644\u0641\u0631\u0642\u0627\u0646","Al-Furqaan"},
				{"\u0627\u0644\u0634\u0639\u0631\u0627\u0621","Ash-Shu'araa"},
				{"\u0627\u0644\u0646\u0645\u0644","An-Naml"},
				{"\u0627\u0644\u0642\u0635\u0635","Al-Qasas"},
				{"\u0627\u0644\u0639\u0646\u0643\u0628\u0648\u062a","Al-Ankaboot"},
				{"\u0627\u0644\u0631\u0648\u0645","Ar-Room"},
				{"\u0644\u0642\u0645\u0627\u0646","Luqman"},
				{"\u0627\u0644\u0633\u062c\u062f\u0629","As-Sajda"},
				{"\u0627\u0644\u0623\u062d\u0632\u0627\u0628","Al-Ahzaab"},
				{"\u0633\u0628\u0625","Saba"},
				{"\u0641\u0627\u0637\u0631","Faatir"},
				{"\u064a\u0633","Yaseen"},
				{"\u0627\u0644\u0635\u0627\u0641\u0627\u062a","As-Saaffaat"},
				{"\u0635","Saad"},
				{"\u0627\u0644\u0632\u0645\u0631","Az-Zumar"},
				{"\u063a\u0627\u0641\u0631","Al-Ghaafir"},
				{"\u0641\u0635\u0644\u062a","Fussilat"},
				{"\u0627\u0644\u0634\u0648\u0631\u0649","Ash-Shura"},
				{"\u0627\u0644\u0632\u062e\u0631\u0641","Az-Zukhruf"},
				{"\u0627\u0644\u062f\u062e\u0627\u0646","Ad-Dukhaan"},
				{"\u0627\u0644\u062c\u0627\u062b\u064a\u0629","Al-Jaathiya"},
				{"\u0627\u0644\u0623\u062d\u0642\u0627\u0641","Al-Ahqaf"},
				{"\u0645\u062d\u0645\u062f","Muhammad"},
				{"\u0627\u0644\u0641\u062a\u062d","Al-Fath"},
				{"\u0627\u0644\u062d\u062c\u0631\u0627\u062a","Al-Hujuraat"},
				{"\u0642","Qaaf"},
				{"\u0627\u0644\u0630\u0627\u0631\u064a\u0627\u062a","Adh-Dhaariyat"},
				{"\u0627\u0644\u0637\u0648\u0631","At-Tur"},
				{"\u0627\u0644\u0646\u062c\u0645","An-Najm"},
				{"\u0627\u0644\u0642\u0645\u0631","Al-Qamar"},
				{"\u0627\u0644\u0631\u062d\u0645\u0646","Ar-Rahmaan"},
				{"\u0627\u0644\u0648\u0627\u0642\u0639\u0629","Al-Waaqia"},
				{"\u0627\u0644\u062d\u062f\u064a\u062f","Al-Hadid"},
				{"\u0627\u0644\u0645\u062c\u0627\u062f\u0644\u0629","Al-Mujaadila"},
				{"\u0627\u0644\u062d\u0634\u0631","Al-Hashr"},
				{"\u0627\u0644\u0645\u0645\u062a\u062d\u0646\u0629","Al-Mumtahana"},
				{"\u0627\u0644\u0635\u0641","As-Saff"},
				{"\u0627\u0644\u062c\u0645\u0639\u0629","Al-Jumu'a"},
				{"\u0627\u0644\u0645\u0646\u0627\u0641\u0642\u0648\u0646","Al-Munaafiqoon"},
				{"\u0627\u0644\u062a\u063a\u0627\u0628\u0646","At-Taghaabun"},
				{"\u0627\u0644\u0637\u0644\u0627\u0642","At-Talaaq"},
				{"\u0627\u0644\u062a\u062d\u0631\u064a\u0645","At-Tahrim"},
				{"\u0627\u0644\u0645\u0644\u0643","Al-Mulk"},
				{"\u0627\u0644\u0642\u0644\u0645","Al-Qalam"},
				{"\u0627\u0644\u062d\u0627\u0642\u0629","Al-Haaqqa"},
				{"\u0627\u0644\u0645\u0639\u0627\u0631\u062c","Al-Ma'aarij"},
				{"\u0646\u0648\u062d","Nooh"},
				{"\u0627\u0644\u062c\u0646","Al-Jinn"},
				{"\u0627\u0644\u0645\u0632\u0645\u0644","Al-Muzzammil"},
				{"\u0627\u0644\u0645\u062f\u062b\u0631","Al-Muddaththir"},
				{"\u0627\u0644\u0642\u064a\u0627\u0645\u0629","Al-Qiyaama"},
				{"\u0627\u0644\u0627\u0646\u0633\u0627\u0646","Al-Insaan"},
				{"\u0627\u0644\u0645\u0631\u0633\u0644\u0627\u062a","Al-Mursalaat"},
				{"\u0627\u0644\u0646\u0628\u0625","An-Naba"},
				{"\u0627\u0644\u0646\u0627\u0632\u0639\u0627\u062a","An-Naazi'aat"},
				{"\u0639\u0628\u0633","Abasa"},
				{"\u0627\u0644\u062a\u0643\u0648\u064a\u0631","At-Takwir"},
				{"\u0627\u0644\u0625\u0646\u0641\u0637\u0627\u0631","Al-Infitaar"},
				{"\u0627\u0644\u0645\u0637\u0641\u0641\u064a\u0646","Al-Mutaffifin"},
				{"\u0627\u0644\u0625\u0646\u0634\u0642\u0627\u0642","Al-Inshiqaaq"},
				{"\u0627\u0644\u0628\u0631\u0648\u062c","Al-Burooj"},
				{"\u0627\u0644\u0637\u0627\u0631\u0642","At-Taariq"},
				{"\u0627\u0644\u0623\u0639\u0644\u0649","Al-A'laa"},
				{"\u0627\u0644\u063a\u0627\u0634\u064a\u0629","Al-Ghaashiya"},
				{"\u0627\u0644\u0641\u062c\u0631","Al-Fajr"},
				{"\u0627\u0644\u0628\u0644\u062f","Al-Balad"},
				{"\u0627\u0644\u0634\u0645\u0633","Ash-Shams"},
				{"\u0627\u0644\u0644\u064a\u0644","Al-Lail"},
				{"\u0627\u0644\u0636\u062d\u0649","Ad-Dhuhaa"},
				{"\u0627\u0644\u0634\u0631\u062d","Ash-Sharh"},
				{"\u0627\u0644\u062a\u064a\u0646","At-Tin"},
				{"\u0627\u0644\u0639\u0644\u0642","Al-Alaq"},
				{"\u0627\u0644\u0642\u062f\u0631","Al-Qadr"},
				{"\u0627\u0644\u0628\u064a\u0646\u0629","Al-Bayyina"},
				{"\u0627\u0644\u0632\u0644\u0632\u0644\u0629","Az-Zalzala"},
				{"\u0627\u0644\u0639\u0627\u062f\u064a\u0627\u062a","Al-Aadiyaat"},
				{"\u0627\u0644\u0642\u0627\u0631\u0639\u0629","Al-Qaari'a"},
				{"\u0627\u0644\u062a\u0643\u0627\u062b\u0631","At-Takaathur"},
				{"\u0627\u0644\u0639\u0635\u0631","Al-Asr"},
				{"\u0627\u0644\u0647\u0645\u0632\u0629","Al-Humaza"},
				{"\u0627\u0644\u0641\u064a\u0644","Al-Fil"},
				{"\u0642\u0631\u064a\u0634","Quraish"},
				{"\u0627\u0644\u0645\u0627\u0639\u0648\u0646","Al-Maa'un"},
				{"\u0627\u0644\u0643\u0648\u062b\u0631","Al-Kawthar"},
				{"\u0627\u0644\u0643\u0627\u0641\u0631\u0648\u0646","Al-Kaafiroon"},
				{"\u0627\u0644\u0646\u0635\u0631","An-Nasr"},
				{"\u0627\u0644\u0645\u0633\u062f","Al-Masad"},
				{"\u0627\u0644\u0625\u062e\u0644\u0627\u0635","Al-Ikhlaas"},
				{"\u0627\u0644\u0641\u0644\u0642","Al-Falaq"},
				{"\u0627\u0644\u0646\u0627\u0633","An-Naas"},
		};
		TreeMap<Integer, ClientChapter> chapterMap=new TreeMap<Integer, ClientChapter>();
		for (int i=0;i<chapterNames.length;i++) {
			chapterMap.put(i+1,new ClientChapter(i+1,0,chapterNames[i][0],chapterNames[i][1]));
		}
		mainPresenter.setAllChapterMap(chapterMap);
		navigationView.showChapterList(chapterMap);
	}

	public void showUserProgress() {
		navigationView.showUserProgress();
	}

	public Integer getSectionNo(String token) {
		return tokenSectionMap.get(token);
	}

}
